<template>
 <div>
    <detail-banner :sightName="sightName" :bannerImg="bannerImg" :gallaryImgs="gallaryImgs" @change="bannerClick"></detail-banner>
    <detail-header></detail-header>
    <div class="content">
      <detail-list :List="categoryList"></detail-list>
    </div>
 </div>
</template>

<script>
import DetailBanner from './components/Banner'
import DetailHeader from './components/Header'
import DetailList from './components/List'
import axios from 'axios'
export default {
  name: 'Detail',
  components: {
    DetailBanner,
    DetailHeader,
    DetailList
  },
  data () {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      categoryList: []
      // list: [{
      //   title: '成人票',
      //   children: [{
      //     title: '成人三馆联票',
      //     children: [{
      //       title: '成人三馆联票-某平台销售'}]
      //   }, {
      //     title: '成人五馆联票'
      //   }]
      // }, {
      //   title: '儿童票'
      // }, {
      //   title: '老年票'
      // }, {
      //   title: '特惠票'
      // }]
    }
  },
  methods: {
    getDetailInfo () {
      // axios.get('/api/detail.json?id=' + this.$route.params.id)
      axios.get('/api/detail.json', { // 获取json数据
        params: { // 传递参数
          id: this.$route.params.id
        }
      }).then(this.handleGetDataSucc)
    },
    handleGetDataSucc (res) {
      res = res.data
      if (res.ret && res.data) {
        const data = res.data
        // console.log(data)
        this.sightName = data.sightName // 景点名称
        this.bannerImg = data.bannerImg // 幻灯片
        this.gallaryImgs = data.gallaryImgs // 画廊
        this.categoryList = data.categoryList // 列表区
      }
    },
    bannerClick () {
      return this.gallaryImgs
    }
  },
  mounted () {
    this.getDetailInfo()
  }
}
</script>

<style lang="stylus" scoped>
  .content
    height 50rem
</style>
